<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>创建合同订单</title>
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <script src="${ctxStatic}/js/DateTimePicker.js"></script>
    <script src="${ctxStatic}/js/layer.js"></script>
    <script src="${ctxStatic}/js/style.js"></script>
    <script src="${ctxStatic}/dateCalendar/WdatePicker.js"></script>
    <link rel="stylesheet" href="${ctxStatic}/css/common.css">
    <link rel="stylesheet" href="${ctxStatic}/css/layerSm.css">
    <script type="text/javascript">
    $(document).ready(function(){
    	var form = $("#inputForm");  
        form.validate();//验证指定的表单
    	$("#userGroupID2").select2();
    	$("#userGroupID").select2();
   		$("#okButton").click(function(){
    		if (form.valid()) {//如果表单验证成功，则进行提交。  
    		$("#showHtml").addClass("showHtml");
            $("#okHead").show();
            $("#createHead").hide();  
            $("#advanceDueDate").removeClass("laydate-icon");
            $("#appDate").removeClass("laydate-icon");
            return false;
          	}
     	});
    });
    
    /* 保存创建/编辑信息 */
    function saveForm(){
    	var params = $("#inputForm").serialize();
    	$.post("${ctx}/produce/plan/save",params,function(result){
    		/* 弹出提示框,刷新父页面,关闭当前页面 */
    		tipParent(result.message);
    		 window.parent.frames[0].searchListForm();
    		closeWin();
    	},'json');
    	
    }
    // 合同订单选择回调
    function selectIndentCallBack(indentId){
		var param = {
				"indentId" : indentId
			};
        // 调用后台更新数据
        $.post("${ctx}/produce/notice/form",param,function(result) {
            // 回调函数赋值
            var h = $(callBackHtml(result)).find("#orderMaterierInfo").html();
            $('#orderMaterierInfo').html(h);
        }, 'html');
    }
    //创建一条新的生产制单 
    function createNewLicence() {
	    	popup('1000px','650px','${ctx}/produce/notice/createNewLicense?id=${produceNotice.id}');
	    	/* if (confirm("确定创建新的生产制单吗？")) {
	    	var param = {
					"id" : "${produceNotice.id}"
				};
	    	
	        // 调用后台更新数据
	        $.post("${ctx}/produce/notice/createNewLicense",param,function(result) {
	        	if (result == "true") {
					tipParent("生产制单创建成功");
					closeWin();
				}else{
					tipParent("保存失败");
				}
	        }, 'json');
		} */
	}
    
  	//创建出库申请画面
	function inventoryRequestEx(){
		var contractID = $("#contractId").val();
		var ognizationId = $("#ognizationId").val();
		var indentId = $("#indentId").val();
		popup('900px','584px','${ctx}/produce/notice/inventoryRequestEx?contractID='+contractID+'&venderId='+ognizationId+'&indentID='+indentId);
	}
    </script>
    <style type="text/css">
    .linkBox{
	color:#0a6dca;
	cursor:pointer;
	text-decoration:underline;
	}
	.showHtml input{
	border:none;
	background-color:inherit;
	color:#333;
	}
    </style>
</head>
<form id="inputForm">
<body>   

<div id="createHead" class="layerHeader clearfix">

			<p class="headerTitle">查看生产通知单</p>
      
	
    <div class="headerButton clearfix">
	    <c:if test="${produceNotice.noticeFlag == '0' }">
	    	<!-- 出库申请 -->
		    <button type="button" onclick="inventoryRequestEx()">出库申请</button>
	    </c:if>
    	<c:if test="${produceNotice.materialStatus == 1 }">
	    	<!-- 下达制单 -->
	    	<button type="button" onclick="createNewLicence()">下达制单</button>
    	</c:if>
    	<c:if test="${produceNotice.materialStatus != 2 }">
        <!-- 编辑 -->
        <button type="button" onclick="window.location.href='${ctx}/produce/notice/editNotice?id=${produceNotice.id}'"><spring:message code="purchaseAdvance_edit_edit"/></button>
        </c:if>
        <!-- 取消 -->
        <button type="button" onclick="closeWin()"><spring:message code="purchaseAdvance_edit_cancle"/></button>
    </div>
</div>

<div id="showHtml" class="smOrderBox showHtml">
		<c:if test="${producePlan.id != null&&producePlan.id!=0}">
        <input type="hidden" id="id" name="id" value="${producePlan.id }">
    <div class=" clearfix" >
        	<!-- 计划排期信息  -->
        	<p class="title" style="margin-top: 2px">计划排期信息</p>
        </div>
    <div class="items clearfix showHtml">
        <div class="col-33 clearfix">
        <!-- 计划订单编码 -->
            <p class="tit" style="width: 80px">计划订单编码</p>
            <input type="hidden" id="planID" name="planID" value="${producePlan.id }">
            <label>${producePlan.planNO }</label>
        </div>
        <div class="col-33 clearfix">
        <!-- 计划订单数量 -->
            <p class="tit" style="width: 80px">计划订单数量</p>
             <label>${producePlan.planQuantity }</label>
        </div>
        <div class="col-33 clearfix">
        <!-- 客户名称 -->
            <p class="tit" style="width: 80px">客户名称</p>
             <label>${producePlan.ognizationName }</label>
        </div>
        
    </div>
    <div class="items clearfix showHtml">
        <div class="col-33 clearfix">
        <!-- 计划生产班组  -->
            <p class="tit" style="width: 80px">计划生产班组</p>
            <select id="userGroupID2" style="width: 150px">
                   <option value="0"><spring:message code="order_please_choose"/></option>
                   <c:forEach items="${groupList}" var="group">
                       <option value="${group.userGroupID}" <c:if test="${producePlan.userGroupID eq group.userGroupID }">selected="selected"</c:if>>${group.groupName}</option>
                   </c:forEach>
            </select>
        </div>
        <div class="col-33 clearfix">
                <!-- 单人生产效率 -->
                    <p class="tit" style="width: 80px">单人生产效率</p>
                    <label>${producePlan.planEfficiency }</label>&ensp;(件/人)
                </div>
        <div class="col-33 clearfix">
                <!-- 计划投产人数  -->
                    <p class="tit" style="width: 80px">计划投产人数</p>
                    <label>${producePlan.planNumber }</label>&ensp;(人)
                </div>
   		</div>
    
            <div class="items clearfix showHtml">        	
                <div class="col-33 clearfix">
                <!-- 计划生产周期  -->
                    <p class="tit" style="width: 80px">计划生产周期</p>
                    <label>${producePlan.planPeriod }</label>&ensp;(天)
                </div>                	
                <div class="col-33 clearfix">
                <!-- 计划开始日期 -->
                    <p class="tit" style="width: 80px">计划开始日期</p>
                    <label><fmt:formatDate value="${producePlan.planBeginDate }" pattern="yyyy-MM-dd" /></label>
                </div>
                <div class="col-33 clearfix">
                <!-- 计划清活日期 -->
                    <p class="tit" style="width: 80px">计划清活日期</p>
                    <label><fmt:formatDate value="${producePlan.planEndDate }" pattern="yyyy-MM-dd" /></label>
                </div>
            </div>
            <div class="items clearfix showHtml">
            	<div class="col-33 clearfix">
                <!-- 计划交货日期 -->
                    <p class="tit" style="width: 80px">计划交货日期</p>
                    <label><fmt:formatDate value="${producePlan.planDeliveryDate }" pattern="yyyy-MM-dd" /></label>
                </div>
            </div>
            <div class="items clearfix showHtml">
                
        		<div class="items clearfix">
        		<!-- 备注 -->
            		<p class="tit" style="width: 80px">备&ensp;&ensp;&ensp;&ensp;注</p>
            		<textarea style="width:790px;height: 60px">${producePlan.remarks }</textarea>
        		</div>
    	</div>
    	</c:if>
    	<div class=" clearfix" >
        	<!-- 生产通知单信息  -->
        	<p class="title" style="margin-top: 2px">生产通知单信息</p>
        </div>
 <div id="orderMaterierInfo">
 <!-- 合同订单id -->
<input type ="hidden" id="indentId" name ="indentId" value="${orderMateriel.indentId}"/>
<!-- 款式id -->
<input type ="hidden" id="styleId" name ="styleId" value="${orderMateriel.styleId}"/>
<!-- 合同id -->
<input type ="hidden" id="contractId" name ="contractId" value="${orderMateriel.contractId}"/>
<!-- 客户id -->
<input type ="hidden" id="ognizationId" value="${orderMateriel.ognizationId}"/>
<c:choose>
   <c:when test="${produceNotice.noticeFlag == '0' }">
   <div class="items clearfix">
        <div class="col-33 clearfix haveToBox">
        <!-- 合同订单号 -->
            <p class="tit" style="width: 80px">合同订单号</p>
            <label>${orderMateriel.indentNo}</label>
            <p class="haveTo">*</p>
        </div>
        <div class="col-33 clearfix">
        <!-- 款　　号 -->
            <p class="tit" style="width: 80px">款　　号</p>
             <label>${orderMateriel.styleCustomerNo}</label>
        </div>
        <div class="col-33 clearfix">
        <!-- 款式名称 -->
            <p class="tit" style="width: 80px">款式名称</p>
             <label>${orderMateriel.styleNameCn}</label>
        </div>
        
    </div>
    <div class="items clearfix">
        <div class="col-33 clearfix">
        <!-- 客户名称 -->
            <p class="tit" style="width: 80px">客户名称</p>
            <label>${orderMateriel.ognizationName}</label>
        </div>
        <div class="col-33 clearfix">
                <!-- 签订日期 -->
                    <p class="tit" style="width: 80px">签订日期</p>
                    <label><fmt:formatDate value="${orderMateriel.indentIssueDate}" pattern="yyyy-MM-dd" /></label>
                </div>
        <div class="col-33 clearfix">
                <!-- 交货日期 -->
                    <p class="tit" style="width: 80px">交货日期</p>
                    <label><fmt:formatDate value="${orderMateriel.indentDeliveryDate}" pattern="yyyy-MM-dd" /></label>
                </div>
    </div>
     </c:when>
   <c:otherwise>
   <div class="items clearfix">
   		<div class="col-33 clearfix">
        <!-- 客户 -->
            <p class="tit" style="width: 80px">客户</p>
            <label>${orderMateriel.ognizationName}</label>
        </div>
        <div class="col-33 clearfix">
        <!-- 定制合同号 -->
            <p class="tit" style="width: 80px">定制合同号</p>
            <label>${orderMateriel.contractNo}</label>
        </div>
        <div class="col-33 clearfix">
        <!-- 计划交货日期 -->
            <p class="tit" style="width: 80px">计划交货日期</p>
            <label>${produceNotice.remarks}</label>
        </div>
   </div>
   </c:otherwise>
   </c:choose>
            <div class="items clearfix">        	
                <div class="col-33 clearfix">
                <!-- 订单数量  -->
                    <p class="tit" style="width: 80px">订单数量</p>
                    <c:if test="${produceNotice.noticeFlag==null||produceNotice.noticeFlag=='0' }">
                    	<label><fmt:formatNumber value="${orderMateriel.indentQuantity}" pattern="#,##0.#####" /></label>
                	</c:if>
                	<c:if test="${produceNotice.noticeFlag!=null&&produceNotice.noticeFlag!='0' }">
                    	<label><fmt:formatNumber value="${produceNotice.noticeQuantity}" pattern="#,##0.#####"/></label>
                	</c:if>
                </div>                	
                
            </div>
 </div>
            <div class="items clearfix">
        <div class="col-33 clearfix haveToBox">
        <!-- 生产班组  -->
            <p class="tit" style="width: 80px">生产班组</p>
            <select id="userGroupID" style="width: 150px">
                   <option value="0"><spring:message code="order_please_choose"/></option>
                   <c:forEach items="${groupList}" var="group">
                       <option value="${group.userGroupID}" <c:if test="${produceNotice.userGroupID eq group.userGroupID }">selected="selected"</c:if>>${group.groupName}</option>
                   </c:forEach>
            </select>
            <p class="haveTo">*</p>
        </div>
         <div class="col-33 clearfix haveToBox">
                <!-- 单人生产效率 -->
                    <p class="tit" style="width: 80px">单人生产效率</p>
                    <label>${produceNotice.noticeEfficiency }</label>&ensp;(件/人)
                    <p class="haveTo">*</p>
                </div>
        <div class="col-33 clearfix haveToBox">
                <!-- 投产人数  -->
                    <p class="tit" style="width: 80px">投产人数</p>
                    <label>${produceNotice.noticeNumber }</label>&ensp;(人)
                	<p class="haveTo">*</p>
                </div>
   		</div>
    
            <div class="items clearfix haveToBox">        	
                <div class="col-33 clearfix">
                <!-- 生产周期  -->
                    <p class="tit" style="width: 80px">计划生产周期</p>
                    <label>${produceNotice.noticePeriod }</label>&ensp;(天)
           			<p class="haveTo">*</p>
                </div>                	
                <div class="col-33 clearfix haveToBox">
                <!-- 开始日期 -->
                    <p class="tit" style="width: 80px">开始日期</p>
                    <label><fmt:formatDate value="${produceNotice.noticeBeginDate }" pattern="yyyy-MM-dd" /></label>
                    <p class="haveTo">*</p>
                </div>
                <div class="col-33 clearfix haveToBox">
                <!-- 清活日期 -->
                    <p class="tit" style="width: 80px">清活日期</p>
                    <label><fmt:formatDate value="${produceNotice.noticeEndDate }" pattern="yyyy-MM-dd" /></label>
                    <p class="haveTo">*</p>
                </div>
            </div>
            <div class="items clearfix haveToBox">        	
                <div class="col-33 clearfix haveToBox">
                <!-- 实际交货日期 -->
                    <p class="tit" style="width: 80px">实际交货日期</p>
                    <label><fmt:formatDate value="${produceNotice.noticeDeliveryDate }" pattern="yyyy-MM-dd" /></label>
                    <p class="haveTo">*</p>
                </div>
            </div>
</div>
</form>
<script>
	window.onload = function(){
	$('.tableScrollSm').css('height','325px')
	$('td input').each(function(){
		var tdH = $(this).parents('td').height()
		$(this).css('height',tdH)
		})
	}
	var tableW = $('.tableHead').outerWidth();
	$('.tableScroll').css('width',tableW + 18 + 'px')
$('.showHtml').find('input,select,textarea').attr('disabled','disabled');
</script>
</body>
</html>
